<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>产品管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
</head>
<body>
<div class="container">
    <div class="flow">
        <div class="itemtitle">
            <h3>产品管理</h3>
        </div>
    </div>
    
    <div class="h35"></div>
    <script type="text/javascript">
    $(function(){
        /* 全选 */
         $('.checkall').click(function(){
            var _self = this;
            $('.checkitem').each(function(){
                if (!this.disabled)
                {
                    $(this).attr('checked', _self.checked);
                }
            });
            $('.checkall').attr('checked', this.checked);
        });	 
    });
    </script>
    <form action="" method="get">
    <input type="hidden" name="m" value="product">
    <input type="hidden" name="s" value="product.php">
    <table class="select_table">
        <tbody>
            <tr>
                <td width="60">产品名称:</td>
                <td width="200"><input id="name" type="text" name="name" class="w200" value="<{$smarty.get.name}>" /></td>
                
                <td width="60">产品ID:</td>
                <td width="200"><textarea id="code" name="code" class="w200" style="resize:horizontal;height:20px;"><{$smarty.get.code}></textarea></td>
                
                <td width="70">产品分类:</td>
                <td width="100">
                 <select class="ws350" name='cat'  id="cat">
                    	<option value='0'>全部分类</option>
                        <{foreach item=list from=$de.cat}>
                        
             			<option <{if $re.cid==$list.catid || $smarty.get.cat==$list.catid}> selected="selected" <{/if}> value="<{$list.catid}>"><{$list.cat}></option>
                           
                            <{foreach item=slist from=$list.scat}>
                            <option <{if $re.cid==$slist.catid || $smarty.get.cat==$slist.catid}> selected="selected" <{/if}> value="<{$slist.catid}>">|__<{$slist.cat}></option>
                            	    
                                    <{foreach item=lists from=$slist.scat}>
                                    <option <{if $re.cid==$lists.catid || $smarty.get.cat==$lists.catid}> selected="selected" <{/if}> value="<{$lists.catid}>">|____<{$lists.cat}></option>
                            		<{/foreach}> 
                                    
                            <{/foreach}> 
                            
                        <{/foreach}> 
            		</select>
                </td>
                <td width="60">品牌：</td>
                <td>
               		<input type="hidden" name="brandid" id="brandid" value="<{$smarty.get.brandid}>"/>
                    <input style="width:150px;" type='text' name='brand' id='brand' value="<{$smarty.get.brand}>" placeholder='输入搜索词' autocomplete="off"/>
            		<ul id="brandlist" style="display:none;position:absolute;background-color:#fff;border: 1px solid rgb(207, 201, 201);width: 150px;">
        			</ul>
                </td>
                <td width="60">标签：</td>
                <td>
                	<select name="tags">
            			<option value="">选择标签</option>
                		<{foreach item=list from=$de.all_tags}>
                        
             				<option <{if  @$list.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$list.id}>"><{$list.tags}></option>
                           
                            <{foreach item=slist from=$list.stags}>
                            	<option  <{if @$slist.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$slist.id}>">|__<{$slist.tags}></option>
                            	    
                                <{foreach item=sslist from=$slist.stags}>
                                <option <{if @$sslist.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$sslist.id}>">|____<{$sslist.tags}></option>
                                    
	                                <{foreach item=lists from=$sslist.stags}>
	                                	<option <{if @$lists.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$lists.id}>">|______<{$lists.tags}></option>
	                           		<{/foreach}>
                           		<{/foreach}> 
                                    
                            <{/foreach}> 
                            
                        <{/foreach}> 
            		</select>
       			</td>
       		</tr>
       		<tr>	
                <td width="60">状态：</td> 
                
                <td width="80"><select name="statu" id="statu"><option value="">全部产品</option>
                <option value="0" <{if "0"===$smarty.get.statu}>selected="selected"<{/if}>>未送审</option>
                <option value="-2" <{if "-2"==$smarty.get.statu}>selected="selected"<{/if}>>已送审</option>
                <option value="1" <{if 1==$smarty.get.statu}>selected="selected"<{/if}>>已上架</option>
                <option value="2" <{if 2==$smarty.get.statu}>selected="selected"<{/if}>>推荐</option>
                <option value="-1" <{if -1==$smarty.get.statu}>selected="selected"<{/if}>>被驳回</option>
                <option value="-3" <{if -3==$smarty.get.statu}>selected="selected"<{/if}>>已下架</option>
                
                </select></td>
                <td width="60">所在仓库：</td> 
                
                <td width="80">
                <select name="stock_shop" id="stock_shop">
                <option value="">全部</option>
                <{foreach item=list from=$de.stock_shops}>
                <option value="<{$list.id}>" <{if $smarty.get.stock_shop==$list.id}>selected<{/if}> ><{$list.show_title}></option>
                
                <{/foreach}>
                </select></td>
								<td width="60">责任编辑：</td> 
                
                <td width="80">
                <select name="admin_user" id="admin_user">
                <option value="">全部</option>
                <{foreach item=list from=$de.admins}>
                <option value="<{$list.user}>" <{if $admin_user==$list.user}>selected<{/if}> ><{$list.name}></option>
                
                <{/foreach}>
                </select></td>
                
                <td width="60">是否在微店：</td> 
                
                <td width="80">
	                <select name="in_micro_shop" id="in_micro_shop">
		                <option value="">全部</option>
		                <option value="0" <{if "0"===$smarty.get.in_micro_shop}>selected="selected"<{/if}>>不在</option>
		                <option value="1" <{if 1==$smarty.get.in_micro_shop}>selected="selected"<{/if}>>在</option>
	                </select>
                </td>
                
                <td><input type="image" src="<{$config.weburl}>/image/admin/search.gif" /></td>
            </tr>
            
        </tbody>
    </table>
    </form>
<!--     <table class="table">
        <tbody>
        <tr>
            <th colspan="99" class="partition">提示</th>
        </tr>
        <tr>
            <td>
                <ul class="tips">
                    <li>通过产品管理，您可以进行编辑产品价格、库存、规格等信息，以及删除产品等操作。</li>
                    <li>请先根据条件搜索产品，然后选择相应的操作。</li>
                </ul>
            </td>
        </tr>
        </tbody>
    </table> -->
       <form method="post" target="export_iframe" id="export_form" action=""><input type="hidden" value="export" name="act"/></form>
    <iframe src="" style="display:none;" id="export_iframe" name="export_iframe"></iframe>
    <form action="?m=product&s=product.php<{$url}>" method="post" id="form" name="form">
    <input type="hidden" name="act" value="op" />
    <input type="hidden" name="type" value="" />
    <table class="table product">
        <thead>
        <tr>
            <th colspan="99" class="partition">
            <ul class="button">
                <li class="button">
                    <a class="a_button" href="?m=product&s=product_launch.php">添加产品</a>
                </li>
               <!--  <li class="button">
                	<a id="unify_price"  class="a_button" href="javascript:void(0);">统一调价</a>
                </li> -->
								<li class="button">
								<a id="unify_limit"  class="a_button" href="javascript:void(0);">统一调限购数量</a>
								</li>


                <li class="button">
                    <a class="a_button w60" href="javascript:void(0);"><span>批量操作</span><em></em></a>
                    <div class="select_btn">
                        <ul>
                        	                 <li class="li">
                    <a class="op_button" type="1" href="javascript:void(0);">上架</a>
                </li>
                <li class="li">
                    <a class="op_button" type="2" href="javascript:void(0);">推荐</a>
                </li>
                <li class="li">
                    <a class="op_button" type="-1" href="javascript:void(0);">驳回</a>
                </li>
                <li class="li">
                    <a class="op_button" type="-3" href="javascript:void(0);">下架</a>
                </li>
                            <li class="li"><a class="op_button" type="-9" href="javascript:void(0);">删除</a></li>
                            <{if 0}><li class="li"><a id="unify_stock" href="javascript:void(0);">统一调库存</a></li><{/if}>
                        </ul>
                    </div>
                </li>
                <!-- <li class="button">
                
                        <a class="a_button" href="javascript:;" id="change_cat">移动分类</a>
                
                </li> -->
            </ul>
            
            <div style="float:right" id="els_export">
            <ul class="button">
            	<li class="button">
							<a href="?m=product&s=product.php&act=export_product<{foreach key=k item=val from=$smarty.get}>&param[<{$k}>]=<{$val}><{/foreach}>"   class="a_button" id="export_product" >主商品导出详情</a>
							</li>
							<li class="button" style="display:none;">
							<a href="?m=product&s=product.php&act=export_product_sku<{foreach key=k item=val from=$smarty.get}>&param[<{$k}>]=<{$val}><{/foreach}>"   class="a_button" id="export_product_sku" >SKU导出详情</a>
							</li>
							<li class="button">
            <a  class="a_button" href="?m=product&s=product.php&act=export_product_id<{foreach key=k item=val from=$smarty.get}>&param[<{$k}>]=<{$val}><{/foreach}>">只导出产品ID</a>
            </li>
						</ul>
						</div>
            </th>
        </tr>
        </thead>
        <tbody>
            <tr class="header">
                <!-- <th width="1"></th> -->
                <th width="15"><input type="checkbox" class="checkall" id="del"></th>
                <th width="40">产品ID</th>
                <th colspan="2">产品名称</th>
                <th width="60">所属标签</th>
                <th width="60">所属活动</th>
                <th width="80">规格</th>
                <th width="80">SKUID</th>
                <th width="55">销售价</th>
                <th width="55">市场价</th>
                <th width="30">库存</th>
                <th width="45">备货期</th>
                <th width="50">状态</th>
                <!-- <th width="70">责任编辑</th> -->
                <th width="65">更新时间</th>
                <th width="15"></th>
            </tr>
            <{foreach item=list from=$de.list}>
            <tr >
                <td><input type="checkbox" value="<{$list.pid}>" class="checkitem" name="chk[]"></td>
                <td><{$list.pid}></td>
                <td class="al" width="80" valign="middle" style="position:relative;">
                	<{if $list.stock_shop}>
                		<i style="background:url(/image/admin/<{$list.stock_shop}>.png);display: block;height: 32px;right: 1px;top:14px;position: absolute;width: 32px;"></i>
                	<{/if}>
                	<a target="_blank" href="http://wx.52ywy.com/item-<{$list.pid}>.html">
                		<img class="img" alt="<{$list.pname}>" src="<{$list.pic}>" width="80" />
                	</a>
                </td>
                <td class="al" width="200">
                <h4><a target="_blank" href="http://wx.52ywy.com/item-<{$list.pid}>.html"><{$list.pname}></a></h4>
                <p>编号：<{$list.code}> &nbsp; SKU：<{$list.setmeal_nums}><{if $list.setmeal_nums>1}> <a href="javascript:;" sku-op="<{$list.pid}>">sku上下架</a> <{/if}></p>
                <p>分类：<{$list.catname}></p>
                <p>所属品牌：<{$list.brand}></p>
                </td>
                
                <td>
                <{foreach item=list_tag from=$list.tags_arr}>
                <p><{$list_tag}></p>
                <{/foreach}>
                </td>
                
                <td>
                <{if $list.actInfo}><a href="javascript:void(0);" title="<{$list.actInfo.title}>" style="color:<{if $list.actInfo.status==2}>gray<{elseif $list.actInfo.status==3}>red<{else}>green<{/if}>;"><{$list.actInfo.activity_id}></a><{else}>暂无<{/if}>
                </td>
                
                <td style="position:relative;">
                <div class="showsku"  style="height:<{if $list.setmeal_nums>5}>90<{else}><{$list.setmeal_nums*18}><{/if}>px; overflow:hidden;">
                <{foreach item=list_spec from=$list.setmeal_spec}>
                <p><{$list_spec}></p>
                <{/foreach}>
                </div>
                </td>
                <td style="position:relative;">
                    <div class="showsku"  style="height:<{if $list.setmeal_nums>5}>90<{else}><{$list.setmeal_nums*18}><{/if}>px; overflow:hidden;">
                        <{foreach item=skuid from=$list.setmeal_skuid}>
                        <p><{$skuid}></p>
                        <{/foreach}>
                    </div>
                </td>
                
                <td style="position:relative;">
                <div class="showsku" style="height:<{if $list.setmeal_nums>5}>90<{else}><{$list.setmeal_nums*18}><{/if}>px; overflow:hidden;">
                <{foreach item=list_price from=$list.setmeal_price}>
                <p><{$config.money}><{$list_price}></p>
                <{/foreach}>
                </div>
                <{if $list.setmeal_nums>5}><em class="skumore" skunums="<{$list.setmeal_nums}>">↓↓↓</em><{/if}>
                </td>
                
                <td style="position:relative;">
                <div class="showsku" style="height:<{if $list.setmeal_nums>5}>90<{else}><{$list.setmeal_nums*18}><{/if}>px; overflow:hidden;">
                <{foreach item=list_market_price from=$list.setmeal_market_price}>
                <p><{$config.money}><{$list_market_price}></p>
                <{/foreach}>
                </div>
                </td>
                <td style="position:relative;">
                <div class="showsku" style="height:<{if $list.setmeal_nums>5}>90<{else}><{$list.setmeal_nums*18}><{/if}>px; overflow:hidden;">
                <{foreach item=list_stock from=$list.setmeal_stock}>
                <p><{$list_stock}></p>
                <{/foreach}>
                </div>
                </td>
                
                <td><{$list.waiting_time_desc}></td>
                
                <td><{if "0"===$list.status}>未送审<{/if}>
                <{if "-2"===$list.status}><span style="color:orange">已送审</span><{/if}>
                <{if "1"===$list.status}><span style="color:green">已上架</span><{/if}>
                <{if "2"===$list.status}><span style="color:blue">推荐</span><{/if}>
                <{if "-1"===$list.status}><span style="color:red">被驳回</span><{/if}>
                <{if "-3"===$list.status}><span style="color:#ccc">已下架</span><{/if}>
                </td>
                <!-- <td><{$list.create_user}></td> -->
                <td><{$list.uptime|date_format:"%Y-%m-%d %H:%M:%S"}></td>
                
                <td>
                <a href="?m=product&s=product_launch.php&edit=<{$list.pid}><{$url}>"><{$editimg}></a>
                </td>
            </tr>
            <{foreachelse}>
            <tr>
                <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
            </tr>
            <{/foreach}>
        </tbody>
        <tfoot>
            <tr>
                <td colspan="99"><div class="page"><{$de.page}></div>共有<{$countpro}>个产品</td>
            </tr>
        </tfoot>
    </table>
    </form>
</div>
<script>

$('.skumore').click(function(){
	
	var skunums=parseInt($(this).attr('skunums'));
	
	var $showdivs=$(this).parent().parent().find('.showsku');
	
	if(skunums<=5){
		return ;
	}else{
		if($(this).html()=='↓↓↓'){
		
		//$showdivs.addClass('overlayout');
		$(this).html('↑↑↑');
		$showdivs.each(function(){
			var h=18*skunums;
			$(this).height(h);
		});
		}else{
			$showdivs.height(90);
			$(this).html('↓↓↓');
		}
	}
	
	
});



//默认待选品牌
$('#brand').bind('click',function(e){
		$.get('<{$config.weburl}>/admin/module.php?m=product&s=product.php&operation=getbrand&brandname=',function(data){
			$('#brandlist').show();
			$('#brandlist').html(""+data);
		});
});
//直接搜品牌
$('#brand').bind('input',function(e){
	var value=$(this).val();
	if(value==''){
		$('#brandlist').hide();
		return ;
	}
	else{
		$.get('<{$config.weburl}>/admin/module.php?m=product&s=product.php&operation=getbrand&brandname='+value,function(data){
			$('#brandlist').show();
			$('#brandlist').html(""+data);
		});
	}
});
$('body').bind('click',function(e){
	$('#brandlist').hide();
});
$('#brandlist').delegate('li','click',function(){
	var _this=$(this);
	var brandName=_this.text();
		var brandId=_this.attr('bid');
		$('#brand').val(brandName);
		$('#brandid').val(brandId);
		$('#brandlist').hide();
});


$.each($('[stock]'),function(){//库存
	//alert($(this).attr('stock'));
	var $stock=$(this);
	
	$.get('<{$config.weburl}>/admin/module.php?m=product&s=inventory_api.php&stock='+$(this).attr('stock'),function(data){
		$stock.html(data);
	});

	
})

$(".op_button").click(function () {
	var obj=$("input[class='checkitem']:checked");
	if(confirm('确认此操作？')){
		if(!obj.length)
		{
			alert("请选择数据，再进行操作!");
			return false;
		}
		//alert($(this).attr('type'));
		$("input[name='type']").val($(this).attr('type'));
	$("#form")[0].submit();
	return false;
	}
});
$("#unify_price").click(function () {
	
	alert('此功能暂缓开通');
	return false;
	
	var obj=$("input[class='checkitem']:checked");
	if(!obj.length)
	{
		alert("请选择数据，再进行操作!");
		return false;
	}
	var str='';
	$.each(obj,function(i){
		str+=$(this).val()+',';
	});
	
	window.parent.iframe_form("unify", '调整价格', '<{$config.weburl}>/admin/module.php?m=product&s=product_unify.php&type=price&id='+str, 800,400);
	return false;
});

$("#unify_limit").click(function () {
	
	var obj=$("input[class='checkitem']:checked");
	if(!obj.length)
	{
		alert("请选择数据，再进行操作!");
		return false;
	}
	var str='';
	$.each(obj,function(i){
		str+=$(this).val()+',';
	});
	
	window.parent.iframe_form("unify", '调整限购', '<{$config.weburl}>/admin/module.php?m=product&s=product_unify.php&type=limit&id='+str, 800,400);
	return false;
});


$("#change_cat").click(function () {
	alert('此功能暂缓开通');
	return false;
	var obj=$("input[class='checkitem']:checked");
	if(!obj.length)
	{
		alert("请选择数据，再进行操作!");
		return false;
	}
	var str='';
	$.each(obj,function(i){
		str+=$(this).val()+',';
	});
	window.parent.iframe_form("change_cat", '移动分类', '<{$config.weburl}>/admin/module.php?m=product&s=product_unify.php&type=cat&id='+str, 800,300);

	
});

$("#unify_stock").click(function () {
		
	var obj=$("input[class='checkitem']:checked");
	if(!obj.length)
	{
		alert("请选择数据，再进行操作!");
		return false;
	}
	var str='';
	$.each(obj,function(i){
		str+=$(this).val()+',';
	});
	
	window.parent.ajax_form("unify", '调整库存', '<{$config.weburl}>/admin/module.php?m=product&s=product_unify.php&type=stock&id='+str, 800);
	return false;
});

$("a[sku-op]").click(function(){
 	alert("此功能暂缓开通!");
		return false;
	var pid =$(this).attr('sku-op');
	window.parent.iframe_form("sku-operation", 'sku上下架', '<{$config.weburl}>/admin/module.php?m=product&s=product_unify.php&type=skuop&id='+pid, 800,300);

	//alert(pid);
})

</script>    
</body>
</html>